package com.service.bean.device;

import java.util.ArrayList;
import java.util.List;

import com.service.bean.alarm.HookArmAlarm;
import com.service.bean.company.Company;
import com.service.bean.point.LabelPoint;
import com.service.bean.signal.GpsHookArmCaseSignal;

/**
 * 勾臂车箱体
 * @author lj
 *
 */
public class HookArmCase {
	/**
	 * 箱体Id
	 */
	public String caseId;
	/**
	 * 箱体名称
	 */
	public String caseName;
	/**
	 * 型号规格
	 */
	public String caseType;
	/**
	 * 箱体容积
	 */
	public String caseBulk;
	/**
	 * 箱体绑定的GPS终端
	 */
	public Device device;
	/**
	 * 箱体所属公司
	 */
	public Company company;
	/**
	 * 车辆上一条Gps信号
	 */
	public GpsHookArmCaseSignal lastGps;
	/**
	 * 从终端收到gps历史数据及经纬度为0的无效数据
	 */
	public GpsHookArmCaseSignal lastGps_Received;
	
	/**
	 * 按时间排序后最新一条Gps信号
	 */
	public GpsHookArmCaseSignal lastGps_lastest;
	
	/**
	 * 垃圾处理场坐标点(D;E)
	 */
	public List<LabelPoint> garbageDisposalSitePoints = new ArrayList<LabelPoint>();
	/**
	 * 上一条报警信息
	 */
	public HookArmAlarm lastAlarm;

	/**
	 * 更新最新时间的signal信号数据
	 */
	public void setLastGps_lastest(GpsHookArmCaseSignal signal){
		if (null == lastGps_lastest 
			|| lastGps_lastest.gpsTime.before(signal.gpsTime))
			lastGps_lastest = signal;
	}
	
	/**
	 * 前端E1命令获取最新时间的signal信号数据
	 */	
	public GpsHookArmCaseSignal getHookArmLastGps_Received() {
		
		if(lastGps_lastest == null){
			return lastGps;
		}
		if(lastGps == null){
			return lastGps_Received;
		}
		
		if (lastGps.gpsTime.before(lastGps_lastest.gpsTime)){
			//历史数据的时间比缓存里的时间新，返回历史数据
			return lastGps_lastest;
		}else{
			return lastGps;
		}		
	}	
	
}
